<template>
  <div>
    <van-cell title="搜索记录">
      <div v-if="isDel">
        <span @click="$emit('update-history',[])"> 全部删除 </span>&nbsp;&nbsp;

        <span @click="isDel=false">完成</span>
      </div>
      <van-icon v-else @click="isDel =true" name="delete" />
    </van-cell>
    <van-cell :title="item" v-for='(item ,i) in searchHistory' @click="onDelete(item,i)" :key="i">
      <van-icon name="close" v-show='isDel' />
    </van-cell>
  </div>
</template>
<script>
export default {
  props: {
    searchHistory: {
      trpe: Array,
      required: true
    }
  },
  data() {
    return {
      isDel: false
    }
  },
  methods: {
    onDelete(item, i) {
      if (this.isDel) {
        this.searchHistory.splice(i, 1)
      } else {
        this.$emit('hehe', item)
      }
    }
  }
}
</script>
<style lang="less" scoped>
</style>
